Skip to content

Commit 0d837ee

Browse files
authored
Merge pull request #6669 from escattone/rename-topic-title-2328
data migration to rename topic title
2 parents 53adde9 + 93d5cdf commit 0d837ee

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

docs/taxonomy/topics_by_product.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ products:
191191
- title: Tracking protection
192192
description: Enable tracking protection to enhance your privacy.
193193
subtopics:
194-
- title: Cookies
194+
- title: Cookies as trackers
195195
description: Troubleshoot cookies issues.
196196
- title: Search, tag, and share
197197
description: Learn about search functionality and how to organize or share content
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Generated by Django 4.2.21 on 2025-05-20 14:23
2+
3+
from django.db import migrations
4+
5+
6+
def update_topic_title(apps, schema_editor):
7+
Topic = apps.get_model("products", "Topic")
8+
9+
try:
10+
topic = Topic.objects.get(
11+
title="Cookies",
12+
is_archived=False,
13+
parent__title="Tracking protection",
14+
parent__is_archived=False,
15+
parent__parent__title="Privacy and security",
16+
parent__parent__is_archived=False,
17+
parent__parent__parent__isnull=True,
18+
)
19+
except Topic.DoesNotExist:
20+
print('The topic "Privacy and security > Tracking protection > Cookies" does not exist.')
21+
except Topic.MultipleObjectsReturned:
22+
print(
23+
'Multiple instances of the topic "Privacy and security > Tracking protection'
24+
' > Cookies" exist.'
25+
)
26+
else:
27+
topic.title = "Cookies as trackers"
28+
topic.save()
29+
print(
30+
'Successfully updated the title of the topic "Privacy and security > Tracking'
31+
' protection > Cookies" to "Cookies as trackers".'
32+
)
33+
34+
35+
class Migration(migrations.Migration):
36+
37+
dependencies = [
38+
("products", "0023_initial_topic_metadata"),
39+
]
40+
41+
operations = [
42+
migrations.RunPython(update_topic_title, migrations.RunPython.noop),
43+
]

0 commit comments

Comments
 (0)